import request from '@/utils/request'

/**
 * 获取企业列表
 *
 * @param { page, pageSize, name } params
 *
 * @returns {Promise}
 */
export function getEnterpriseListAPI(params) {
  return request({
    url: '/park/enterprise',
    method: 'get',
    params
  })
}

/**
 * 查询企业所属行业列表
 *
 * @returns {Promise}
 */
export function getIndustryListAPI() {
  return request({
    url: '/park/industry',
    method: 'get'
  })
}

/**
 * 获取企业详情
 *
 * @param { id } id
 *
 * @returns {Promise}
 */
export function getEnterpriseDetailsAPI(id) {
  return request({
    url: `/park/enterprise/${id}`,
    method: 'get'
  })
}

/**
 * 新增企业
 *
 * @param { name, legalPerson, registeredAddress, industryCode, businessLicenseUrl, businessLicenseId, contact, contactNumber } params
 *
 * @returns {Promise}
 */
export function addEnterpriseAPI(params) {
  return request({
    url: '/park/enterprise',
    method: 'post',
    data: params
  })
}

/**
 * 修改企业
 *
 * @param { id, name, legalPerson, registeredAddress, industryCode, businessLicenseUrl, businessLicenseId, contact, contactNumber } params
 *
 * @returns {Promise}
 */
export function updateEnterpriseAPI(params) {
  return request({
    url: '/park/enterprise',
    method: 'put',
    data: params
  })
}

/**
 * 删除企业
 *
 * @param { id } id
 *
 * @returns {Promise}
 */
export function deleteEnterpriseAPI(id) {
  return request({
    url: `/park/enterprise/${id}`,
    method: 'delete'
  })
}

/**
 * 查看企业租赁信息列表
 *
 * @param { id } id
 *
 * @returns {Promise}
 */
export function getEnterpriseRentListAPI(id) {
  return request({
    url: `/park/enterprise/rent/${id}`,
    method: 'get'
  })
}

/**
 * 删除企业的租赁合同
 *
 * @param { id } id
 *
 * @returns {Promise}
 */
export function deleteEnterpriseRentAPI(id) {
  return request({
    url: `/park/enterprise/rent/${id}`,
    method: 'delete'
  })
}

/**
 * 添加/续租企业的租赁合同
 *
 * @param { buildingId, startTime, endTime, contractUrl, contractId, type, enterpriseId } params
 *
 * @returns {Promise}
 */
export function addEnterpriseRentAPI(params) {
  return request({
    url: '/park/enterprise/rent',
    method: 'post',
    data: params
  })
}

/**
 * 退租租赁合同
 *
 * @param { String } id
 *
 * @returns {Promise}
 */
export function outRentAPI(id) {
  return request({
    url: `/park/enterprise/rent/${id}`,
    method: 'put'
  })
}
